<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /* function num() {
            var a = 0
            for (i=1;i<=100;i++) {
                a += i
            }
            console.log(a);
        }
        num() */

        //利用函数封装来求  1到n 的和。（注意和上面的有变化）
        /* function num(n) {
            var a = 0
            for (i=1;i<=n;i++) {
                a += i
            }
            console.log(a);
            }
            num(n) */

            //求m到n的值
            /* function num(m,n) {
            var a = 0
            for (i=m;i<=n;i++) {
                a += i
            }
            console.log(a);
            }
            num(m,n) */

           // 利用函数来使用冒泡排序
           /*  function num(a) {
                
                var d = 0
                for (i = 0 ; i <= a.length-1; i++) {
                    for (b=0; b<=a.length-i-1; b++) {
                        if (a[b] >a [b+1]) {
                            var c = a[b]
                            a[b] = a[b+1]
                            a[b+1] = c
                        }
                    }
                }
                console.log(a);
            }
            num([5,3,4,1,2]) */


           /*  function num(n) {
            var a = 0
            for (i=0;i<=n;i++) {
                a += i
            }
            console.log(n);
            }
            num()       //undefined
            function num(n) {
            var a = 0
            for (i=0;i<=n;i++) {
                a += i
            }
            console.log(n);
            }
            num(100)    //100 */
    </script>
</body>
</html>